// 创建和初始化数组
var daysOfWeek = new Array()
var daysOfWeek = new Array(7)
var daysOfWeek = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday',
    'Thursday', 'Friday', 'Saturday')

// 直接赋值数组内容
var daysOfWeek = ['Sunday', 'Monday', 'Tuesday', 'Wednesday',
    'Thursday', 'Friday', 'Saturday'];

// 获取数组的长度
console.log(daysOfWeek.length)

// 普通for方式遍历数组
for (var i = 0; i < daysOfWeek.length; i++) {
    console.log(daysOfWeek[i])
}

// 通过foreach遍历数组
daysOfWeek.forEach(item => console.log(item))

// 求菲波那切数列的前20个数字
var fibonacci = []
fibonacci[0] = 1
fibonacci[1] = 1

for (var i = 2; i < 20; i++) {
    fibonacci[i] = fibonacci[i - 1] + fibonacci[i - 2]
}

console.log(fibonacci)
